package com.theme.passport.controller.sys;

import com.theme.common.mvc.utils.PageUtils;
import com.theme.common.mvc.view.R;
import com.theme.passport.entity.SysFontsEntity;
import com.theme.passport.service.SysFontsService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;



/**
 * 字体配置表
 *
 * @author live
 * @email 870459550@qq.com
 * @date 2022-08-17 11:56:44
 */
@RestController
@RequestMapping("sys/fonts")
public class SysFontsController {
    @Autowired
    private SysFontsService sysFontsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:fonts:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = sysFontsService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("sys:fonts:info")
    public R info(@PathVariable("id") Long id){
		SysFontsEntity sysFonts = sysFontsService.getById(id);

        return R.ok().put("fonts", sysFonts);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys:fonts:save")
    public R save(@RequestBody SysFontsEntity sysFonts){
        sysFonts.setCreated(new Date());
        sysFonts.setUpdated(new Date());
		sysFontsService.save(sysFonts);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:fonts:update")
    public R update(@RequestBody SysFontsEntity sysFonts){
        sysFonts.setUpdated(new Date());
		sysFontsService.updateById(sysFonts);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sys:fonts:delete")
    public R delete(@RequestBody Long[] ids){
		sysFontsService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
